#define _CRT_SECURE_NO_WARNINGS 1
////#include<bits/stdc++.h>
////using namespace std;
//////http://oj33.cn/contest.php?cid=1075
////int n, m;
////int fIBC[2000];
////int sum = 0;
////bool used[2000];
////bool flag;
////int ans = 0;
////void dfs(int times)
////{
////	sum += fIBC[times];
////	used[times] = 1;
////	if (sum > m)
////	{
////		sum -= fIBC[times];
////		used[times] = 0;
////		return;
////	}
////	if (sum > ans)
////	{
////		ans = sum;
////	}
////	
////		if (!used[j])
////			dfs(j);
////	sum -= fIBC[times];
////	used[times] = 0;
////}
////int main()
////{
////	cin >> n >> m;
////	for (int i = 0; i < n; i++)
////	{
////		scanf("%d", &fIBC[i]);
////	}
////	for (int i = 0; i < n; i++)
////	{
////		dfs(i);
////	}printf("%d", ans);
////	return 0;
////}
//#include<iostream>
//
//#include<cstdlib>
//using namespace std;
//long long n, c, a[10000], i, m = 0;
//bool flag[1000];
//void dfs(int sum, int t)
//{
//
//	int i;
//
//	if (sum == c) { cout << sum << endl; exit(0); }
//
//	if (sum > c) { return; }
//
//	if (sum > m)m = sum;
//
//	
//
//	for (i = 1; i <= n; i++)  
//
//		if (flag[i])
//		{
//			flag[i] = false;
//			sum += a[i];
//			dfs(sum, t + 1);
//			sum -= a[i];
//			flag[i] = true;
//		}
//
//}
//
//
//int main()
//{
//	cin >> n >> c;
//	for (i = 1; i <= n; ++i)cin >> a[i];
//	for (i = 1; i <= n; ++i)flag[i] = true;   
//	dfs(0, 1);      
//	cout << m << endl;
//
//	return 0;
//
//}
#include<bits/stdc++.h>
using namespace std;
int n, m, c[500];
int dp[10000];
int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; ++i) scanf("%d", &c[i]);
    for (int i = 1; i <= n; ++i)
        for (int j = m; j >= c[i]; --j)
        dp[j] = max(dp[j], dp[j - c[i]] + c[i]);
    printf("%d\n", dp[m]);
    return 0;
}